<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String htmlData = request.getParameter("description") != null
			? request.getParameter("description")
			: "";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP '008_datagrid.jsp' starting page</title>

		<%@include file="/WEB-INF/jsp/public/commons.jspf"%>
		<script type="text/javascript">
		//发送操作
		function doReCycle(kid,op){
			//请求数据
			$.ajax({
				type: 'post' ,
				url:op=='del'?'kpoint_delete.action?model.id='+kid :'kpoint_reCycle.action?model.id='+kid,
				cache:false ,
				dataType:'json' ,
				success:function(result){
					//重新加载list
					$('#t_user').datagrid('reload');
					// 提示信息
					$.messager.show({
						title:result.status , 
						msg:result.message
					});
				} ,
				error:function(result){
					$.messager.show({
						title:result.status , 
						msg:result.message
					});
				}
			});
		}
		
	$(function() {

		$('#t_user')
				.datagrid(
						{
							idField : 'id', //只要创建数据表格 就必须要加 ifField
							title : '知识点列表',
							//width:1300 ,
							fit : true,
							height : 450,
							url : 'kpoint_listJson.action?status=4',
							fitColumns : true,
							striped : true, //隔行变色特性 
							loadMsg : '数据正在加载,请耐心的等待...',
							rownumbers : true,
							rowStyler : function(index, record) {
							},
							frozenColumns : [ [ //冻结列特性 ,不要与fitColumns 特性一起使用 
							{
								field : 'ck',
								width : 50,
								checkbox : true
							} ] ],
							columns : [ [
									{
										field : 'name',
										title : '知识点名',
										width : 100,
										align : 'center',
										formatter : function(value, record,
												index) {
											//console.info(record);
											return "<a title='kpoint_show.action?model.id="
													+ record.id
													+ "' onclick=parent.addWin(this)>"
													+ value + "";
										}
									},
									{
										field : 'definition',
										title : '定义',
										width : 100,
										hidden : true
									},
									{
										field : 'defficulty',
										title : '难度',
										width : 50,
										formatter : function(value, record,
												index) {
											if (value == 1) {
												return '非常简单';
											} else if (value == 2) {
												return '简单';
											} else if (value == 3) {
												return '中等';
											} else if (value == 4) {
												return '困难';
											} else if (value == 5) {
												return '非常简单';
											}
										}
									},
									{
										field : 'goal',
										title : '目标',
										width : 50,
										formatter : function(value, record,
												index) {
											if (value == 1) {
												return '了解';
											} else if (value == 2) {
												return '掌握';
											} else if (value == 3) {
												return '应用';
											}
										}
									},
									{
										field : 'period',
										title : '学时',
										width : 100,
										sortable : true
									},
									{
										field : 'navifation',
										hidden : true
									} ,
									{
										field : 'reCycle',
										title : '操作',
										width : 100,
										formatter : function(value, record,index) {

												return "<a style='color:blue' onclick=doReCycle("+record.id+",'recover')>恢复 </a> "+
											"<a style='color:red' onclick=doReCycle("+record.id+",'del')>永久删除</a>";
										}
									}
								]],
							pagination : true,
							pageSize : 10,
							pageList : [ 5, 10, 15, 20, 50 ],
						});


	
		
	});
</script>
	</head>

	<body>

		<div id="lay" class="easyui-layout" style="width: 100%; height: 100%">

			<div region="center">
				<table id="t_user"></table>
			</div>
		</div>

	</body>
</html>
